define(function (require, exports, module) {
    require('jquery');
    var angular = require('angular');
    var util = require("util");
    require('angular-route');
    var side = require('/public/js/myservice/side');
    require('/public/js/myservice/contract/editinc/base-ctrl.js?v=20160715');
    require('/public/js/myservice/contract/editinc/balance-ctrl.js?v=20160318');
    require('/public/js/myservice/contract/editinc/docs-ctrl');
    require('/public/js/myservice/contract/editinc/dredge-ctrl');
    require('/public/js/myservice/contract/editinc/income-ctrl');
    require('/public/js/myservice/contract/editinc/performance-ctrl');
    require('/public/js/myservice/contract/editinc/receivable-ctrl');
    require('/public/js/myservice/authorize');

    var hasRight = false;
    // 获取平台json数据
    var getEditContractNavData = function () {
        checkRight();
        var nav = {
            "data": [
                {
                    "id": "menu_home",
                    "name": "基本信息",
                    "level": 1,
                    "iconCls": "",
                    "url": ["/contract/edit_caibao.shtml#/base"],
                    "children": null
                },
                {
                    "id": "menu_building",
                    //"name": "应收信息",
                    "name": "发票信息",
                    "level": 1,
                    "iconCls": "",
                    "url": ["/contract/edit_caibao.shtml#/caibaoinvoice"],
                    "children": null,
                    isVisible: function () {
                        return location.hash.match(/\W(?=id=)/ig) ? true : false;
                    }
                },
                {
                    "id": "menu_building",
                    "name": "回款信息",
                    "level": 1,
                    "iconCls": "",
                    "url": ["/contract/edit_caibao.shtml#/caibaorefund"],
                    "children": null,
                    isVisible: function () {
                        return location.hash.match(/\W(?=id=)/ig) ? true : false;
                    }
                },
                {
                    "id": "menu_building",
                    "name": "收入信息",
                    "level": 1,
                    "iconCls": "",
                    "url": ["/contract/edit_caibao.shtml#/income"],
                    "children": null,
                    isVisible: function () {
                        return location.hash.match(/\W(?=id=)/ig) ? true : false;
                    }
                }
            ]
        };

        if (hasRight) {
            nav.data.push({
                "id": "menu_building",
                "name": "合同文档",
                "level": 1,
                "iconCls": "",
                "url": ["/contract/edit_caibao.shtml#/docs"],
                "children": null,
                isVisible: function () {
                    return location.hash.match(/\W(?=id=)/ig) ? true : false;
                }
            });

        }
        return nav.data;
    };

    var checkRight = function () {
        util.myAjax({
            url: G_CONFIG.api_prefix + "site/check-action",
            type: "post",
            dataType: "json",
            async: false,
            data: {
                actionId: '0001'
            },
            success: function (res) {
                if (res['retCode']) {
                    hasRight = true;
                }
            },
            error: function () {
                hasRight = false;
            }
        });
    };

    side.init(getEditContractNavData());
    angular.module('myContractEditApp', ['ngRoute', 'ContractBase', 'ContractIncome', 'ContractBalance', 'ContractDocs', 'ContractDredge',
        'ContractPerformance', 'ContractReceivable'])
        .controller('contractEditCtrl', function ($scope) {

        })
        .config(['$routeProvider',
            function ($routeProvider) {
                $routeProvider
                    .when('/base', {
                        templateUrl: 'editinc/base.html'
                    })
                    .when('/caibaoinvoice', {
                        templateUrl: 'editinc/caibao-invoice-list.html'
                    })
                    .when('/caibaorefund', {
                        templateUrl: 'editinc/caibao-refund-list.html'
                    })
                    .when('/income', {
                        templateUrl: 'editinc/income.html'
                    })
                    .when('/docs', {
                        templateUrl: 'editinc/docs.html'
                    })
            }]);
    angular.bootstrap(document, ['myContractEditApp']);
});